﻿using System;
using System.Collections.Generic;
using Dict.Config;


namespace Battle.Engine.LogicModel
{
    public class BuffCondition
    {
        public string type;
        public int src1;
        public double src1_val;
        public int op;
        public string type2;
        public int src2;
        public double src2_val;
        public double op_val;

        public FActor actor;

        public virtual void init(FActor actor, string args)
        {
            this.actor = actor;
            this.op_val = 0;
            this.type2 = "";
            string[] sArray = args.Split(',');
            foreach (string sParam in sArray)
            {
                var param = sParam.Split(':');
                if (param[0].Equals("type"))
                {
                    this.type = param[1];
                }
                if (param[0].Equals("src1"))
                {
                    this.src1 = int.Parse(param[1]);
                }
                if (param[0].Equals("src1_val"))
                {
                    this.src1_val = Convert.ToDouble(param[1]);
                }
                if (param[0].Equals("op"))
                {
                    this.op = int.Parse(param[1]);
                }
                if (param[0].Equals("type2"))
                {
                    this.type2 = param[1];
                }
                if (param[0].Equals("src2"))
                {
                    this.src2 = int.Parse(param[1]);
                }
                if (param[0].Equals("src2_val"))
                {
                    this.src2_val = Convert.ToDouble(param[1]);
                }
                if (param[0].Equals("op_val"))
                {
                    this.op_val = Convert.ToDouble(param[1]);
                }
            }
            if(this.type2.Equals(""))
            {
                this.type2 = this.type;
            }
        }

        public virtual bool IsConditionTure(FActor target)
        {
            //默认无条件时，判断直接返回true，表示生效
            return true;
        }
    }
}
